<?php
/*
	本插件：$this->model('worker')->方法名();
	其他地方调用：model('jy_scrm/worker')->方法名();
*/
namespace jy_scrm;
defined('BY_JYA') or exit('error');
class sale extends \plugin{
	public function check_sharelog($gameid,$sharemid=0){
		$isadd=pdo_getcolumn('jy_scrm_sale_gamelog',array('sharemid'=>$sharemid,'gameid'=>$gameid,'uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']),'id');
		return $isadd?:false;
	}
	public function up_sharelog($gameid,$sharemid=0){
		pdo_getcolumn('jy_scrm_sale_gamelog',array('status'=>1),array('sharemid'=>$sharemid,'gameid'=>$gameid,'uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
		return true;
	}
	public function add_sharelog($gameid,$sharemid=0,$type=1){
		$isadd=$this->check_sharelog($gameid,$sharemid);
		if($isadd){
			return false;
		}
		$data=array(
			'gameid'=>$gameid,
			'sharemid'=>$sharemid,
			'mid'=>$params['userid'],
			'uniacid'=>$_SESSION['uniacid'],
			'merchid'=>$_SESSION['onemerchid'],
			'mid'=>$_SESSION['uid'],
			'type'=>$type,
			'createtime'=>time();
		);
		$this->pdo_insert('sale_gamelog',$data);
		return true;
	}
}
?>